package com.tudouji.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.system.domain.Upimage;
import com.tudouji.project.system.service.IUpimageService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 上传图片Controller
 * 
 * @author tudouji
 * @date 2021-05-12
 */
@RestController
@RequestMapping("/system/upimage")
public class UpimageController extends BaseController
{
    @Autowired
    private IUpimageService upimageService;

    /**
     * 查询上传图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:upimage:list')")
    @GetMapping("/list")
    public TableDataInfo list(Upimage upimage)
    {
        startPage();
        List<Upimage> list = upimageService.selectUpimageList(upimage);
        return getDataTable(list);
    }

    /**
     * 导出上传图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:upimage:export')")
    @Log(title = "上传图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Upimage upimage)
    {
        List<Upimage> list = upimageService.selectUpimageList(upimage);
        ExcelUtil<Upimage> util = new ExcelUtil<Upimage>(Upimage.class);
        return util.exportExcel(list, "upimage");
    }

    /**
     * 获取上传图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:upimage:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(upimageService.selectUpimageById(guid));
    }

    /**
     * 新增上传图片
     */
    @PreAuthorize("@ss.hasPermi('system:upimage:add')")
    @Log(title = "上传图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Upimage upimage)
    {
        return toAjax(upimageService.insertUpimage(upimage));
    }

    /**
     * 修改上传图片
     */
    @PreAuthorize("@ss.hasPermi('system:upimage:edit')")
    @Log(title = "上传图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Upimage upimage)
    {
        return toAjax(upimageService.updateUpimage(upimage));
    }

    /**
     * 删除上传图片
     */
    @PreAuthorize("@ss.hasPermi('system:upimage:remove')")
    @Log(title = "上传图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(upimageService.deleteUpimageByIds(guids));
    }
}
